package entity.sparemanage.dto;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import entity.sparemanage.SpareParts;

public class selAllRequisitionWrapper {
    public QueryWrapper<SpareParts> sparePartsQueryWrapper (requisitionDto requisitionDto){
        QueryWrapper<SpareParts> queryWrapper = new QueryWrapper<>();
        if (requisitionDto.getCodeName()!=null){
            String codeName = requisitionDto.getCodeName();
            queryWrapper.like("procure_code",codeName).or().like("procure_theme",codeName);
        }
        if (requisitionDto.getPurchaseNumber()!=null){
            queryWrapper.like("procure_code",requisitionDto.getPurchaseNumber());
        }
        if (requisitionDto.getPurchaseTheme()!=null){
            queryWrapper.like("procure_theme",requisitionDto.getPurchaseTheme());
        }
        if (requisitionDto.getPurchaseDate()!=null){
            queryWrapper.eq("procure_time",requisitionDto.getPurchaseDate());
        }
        if (requisitionDto.getPurchasePerson()!=null){
            queryWrapper.eq("procure_personid",requisitionDto.getPurchasePerson());
        }
        if (requisitionDto.getApplicant()!=null){
            queryWrapper.eq("procure_applicantid",requisitionDto.getApplicant());
        }
        if (requisitionDto.getOperationTime()!=null){
            queryWrapper.eq("update_time",requisitionDto.getOperationTime());
        }
        if (requisitionDto.getDepartment()!=null){
            queryWrapper.eq("procure_departid",requisitionDto.getDepartment());
        }
        if (requisitionDto.getStatus()!=null){
            queryWrapper.eq("audit_status",requisitionDto.getStatus());
        }
        return queryWrapper;
    }
}
